package com.wangchao.administrator.zenmechi.ui.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.wangchao.administrator.zenmechi.R;
import com.wangchao.administrator.zenmechi.ui.fragment.userfragment.userMsg;
import com.wangchao.administrator.zenmechi.ui.loginactivity.LoginActivity;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

                        
import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2016/10/17.
 */
public class UserFragment extends Fragment implements View.OnClickListener {

    @BindView(R.id.tv_top_user)
    TextView tvTopUser;
    @BindView(R.id.tv_setting)
    TextView tvSetting;
    @BindView(R.id.iv_user)
    ImageView ivUser;
    @BindView(R.id.btn_login)
    TextView btnLogin;
    @BindView(R.id.tv_money1)
    TextView tvMoney1;
    @BindView(R.id.tv_YuE)
    TextView tvYuE;
    @BindView(R.id.tv_money2)
    TextView tvMoney2;
    @BindView(R.id.tv_DongJie)
    TextView tvDongJie;
    @BindView(R.id.tv_money3)
    TextView tvMoney3;
    @BindView(R.id.tv_JiFen)
    TextView tvJiFen;
    @BindView(R.id.iv_DaiSong)
    ImageView ivDaiSong;
    @BindView(R.id.tv_DaiSong)
    TextView tvDaiSong;
    @BindView(R.id.iv_PeiSong)
    ImageView ivPeiSong;
    @BindView(R.id.tv_PeiSong)
    TextView tvPeiSong;
    @BindView(R.id.iv_ShouHuo)
    ImageView ivShouHuo;
    @BindView(R.id.tv_ShouHuo)
    TextView tvShouHuo;
    @BindView(R.id.tv_money)
    TextView tvMoney;
    @BindView(R.id.tv_Shouzhi)
    TextView tvShouzhi;
    @BindView(R.id.tv_sale)
    TextView tvSale;
    @BindView(R.id.tv_Favorite)
    TextView tvFavorite;
    @BindView(R.id.tv_health)
    TextView tvHealth;
    @BindView(R.id.tv_us)
    TextView tvUs;
    @BindView(R.id.tv_version)
    TextView tvVersion;
    @BindView(R.id.tv_userName)
    TextView tvUserName;
    private View view;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fragment_user, container, false);
        ButterKnife.bind(this, view);
        initListener();
        EventBus.getDefault().register(this);
        return view;
    }

    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onEventMainThread(userMsg userMsg) {
        tvUserName.setText(userMsg.getMsg());
        tvUserName.setVisibility(View.VISIBLE);
        btnLogin.setVisibility(View.GONE);
    }

    private void initListener() {
        btnLogin.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        Intent login = new Intent(getActivity(), LoginActivity.class);
        startActivity(login);
    }
}
